//
//  TintView.m
//  Toyohu
//
//  Created by Heige on 16/5/11.
//  Copyright © 2016年 celia. All rights reserved.
//

#import "TintView.h"
#import "UIView+Fillet.h"
typedef void (^SuccessBlock)(void);

@interface TintView ()
@property (nonatomic, copy) SuccessBlock successBlock;
@property (weak, nonatomic) IBOutlet UIView *bgView;
//@property (weak, nonatomic) IBOutlet UIButton *cancelButton;
//@property (weak, nonatomic) IBOutlet UIButton *sureButton;

@end


@implementation TintView


-(instancetype)initWithSuccessBlock:(void (^)(void))successBlock
{
    self = [[[NSBundle mainBundle] loadNibNamed:@"TintView" owner:self options:nil] objectAtIndex:0];
    if (self) {
        _successBlock = successBlock;

        self.frame = [[UIScreen mainScreen]bounds];
         [self initView];
        [[[UIApplication sharedApplication] keyWindow] addSubview:self];
    }
    return self;
}

- (IBAction)cancel:(id)sender {
    
    [self removeFromSuperview];
}
- (IBAction)sureButton:(id)sender {
    [self removeFromSuperview];
    if (self.successBlock) {
        self.successBlock();
    }
}

- (void)initView
{
    self.cancelButton.layer.cornerRadius = self.cancelButton.frame.size.height/2;
    self.cancelButton.clipsToBounds  = YES;
    self.cancelButton.layer.borderWidth = 1;
    self.cancelButton.layer.borderColor = [UIColor lightGrayColor].CGColor;
    
    self.sureButton.layer.cornerRadius = self.cancelButton.frame.size.height/2;
    self.sureButton.clipsToBounds  = YES;
    
    [self.bgView filletWithcornerRadius:8.0f];
}



@end
